package com.example.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.entity.Product;
import com.example.mapper.ProductMapper;
import com.example.service.ProductService;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ProductServcieImpl extends ServiceImpl<ProductMapper, Product> implements ProductService {
    @Override
    public void addProduct(Product product) {
        this.save(product);
    }

    @Override
    public void addProduct1(Product product) {
        baseMapper.addProduct(product.getName());
    }

    @Override
    public void updatePro(Product product) {
        this.updateById(product);
    }

    @Override
    public void updatePro1() {
        baseMapper.updatePro1();
    }

    @Override
    public void updatePro2(Product product) {
        baseMapper.updatePro2(product);
    }

    @Override
    public List<Product> getPorduct() {
        Product product = new Product();
        return baseMapper.selectPorduct(product,"admin");
    }

    @Override
    public List<Product> getData2() {
        QueryWrapper<Product> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("create_by","admin");
        return this.list();
    }

    @Override
    public Product getData3() {
        Product p = new Product();
        UpdateWrapper<Product> wrapper = new UpdateWrapper<>();
        this.update(p,wrapper);
        return p;
    }


}
